package com.hzxcloudserviceb.kafka;

import com.hzxcloudserviceb.message.MessageData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.kafka.core.KafkaTemplate;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.UUID;

/**
 * Created by huzuxing on 2021/4/28.
 */
@Component
public class MessageSender {
    @Autowired
    private KafkaTemplate<String, String> kafkaTemplate;

    public void send(int i) {
        MessageData messageData = new MessageData();
        messageData.setId(i);
        messageData.setName(UUID.randomUUID().toString());
        messageData.setSendTime(new Date());
        kafkaTemplate.send("wqh",messageData.toString());
    }
}
